package com.zhiyun.yycall.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.gzit.utils.AndroidUtils;
import com.zhiyun.trace.TraceActivity;
import com.zhiyun.yycall.R;

public class SettingActivity extends TraceActivity {

	OnClickListener listener = new OnClickListener() {

		@Override
		public void onClick(View v) {

			switch (v.getId()) {
			case R.id.logout_btn:
				gotoLoginActivity();
				break;

			case R.id.goto_about:
				gotoAboutActivity();
				break;
			case R.id.goto_help:
				gotoHelpActivity();
				break;
			case R.id.invite_container:
				gotoInviteActivity();
				break;
			case R.id.change_pwd_btn:
				gotoChangePwdActivity();
				break;

			}

		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.setting_activity);

		for (int id : new int[] { R.id.logout_btn, R.id.goto_about,
				R.id.goto_help, R.id.invite_container, R.id.change_pwd_btn }) {
			this.findViewById(id).setOnClickListener(listener);
		}

		((TextView) this.findViewById(R.id.version)).setText("V"
				+ AndroidUtils.System.getVersionName());

	}

	private void gotoChangePwdActivity() {

		Intent intent = new Intent();
		intent.setClass(this, ChangePwdActivity.class);
		this.startActivity(intent);

	}

	private void gotoInviteActivity() {

		Intent intent = new Intent();
		intent.setClass(this, InviteActivity.class);
		this.startActivity(intent);

	}

	private void gotoHelpActivity() {
		Intent intent = new Intent();
		intent.setClass(this, HelpActivity.class);
		this.startActivity(intent);
	}

	private void gotoAboutActivity() {
		Intent intent = new Intent();
		intent.setClass(this, AboutActivity.class);
		this.startActivity(intent);
	}

	private void gotoLoginActivity() {
		Intent intent = new Intent();
		intent.setClass(this, LoginActivity.class);
		this.startActivity(intent);
		this.finish();
	}

}
